Xbasic

a5Storage_saveData Function

Syntax

L a5Storage_saveData(C connectionString ,b blob ,C itemName [,C mimeType [,* pResult, [L flagSetReadPermission [,L flagOverwriteExistingObject]]]])

Arguments

connectionString

Character. Storage connection string with ::storage:: as a prefix.

blob

name of the blob to save in storage.

itemName

Character. name of the object in storage. You can can specify a logical folder by using forward slashes in the name. For example: image/image1.jpg

mimeType

Character. the mime type of the object. If you don't specify this property, the value can be inferred from the extension you assign to the itemName property. See Media types for a list of mime types.

pResult

* An optional dot variable that you can pass in that will be populated with information about the object.

flagSetReadPermissionLogical

Default = .f.. If set to .t., adds read access to the object for everyone.

flagOverwriteExistingObjectLogical

Default = .t.. If .t., if an object already exists in the storage with the same name, the object is replaced by the uploaded data. Otherwise, the uploaded data is assigned a unique name. If the object is renamed and you pass in the optional pResult parameter, the actual object name that was used to save the new object is available in the pResult.actualItemName property.

Description

Saves data to storage, including saving files to Amazon S3 or Azure. Same as a5Storage_saveFile(), except takes a blob as input rather than a filename.

dim img64 as c = "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="
dim decodedImg as b
decodedImg = base64decode(img64)

dim filename as c = "mydata.png"
dim mime as c = "image/png"
dim result as P
a5storage_savedata("::storage::disk",decodedImg,filename,mime,result)

? result
= AbsolutePath = "file://C:\Users\user1\Documents\AlphaAnywhere\Demo\Demo.WebProjects\Default.WebProject\images\mydata.png"
ContentType = "image/x-png"
hasError = .F.
ModifiedTime = 05/06/2021 12:29:25 64 pm
Name = "mydata.png"
size = 85
timeTakenMilliseconds = 5

See Also